$(document).ready(function(){
       // form validation
       $('.validate_form').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        }
    }).on('success.form.bv', function(e) {
        var $form = $(e.target);
        var isSuccess=$form.attr("isSuccess");        
        if(isSuccess==="0" || typeof isSuccess==="undefined"){
            e.preventDefault();
           
            $.ajax({
                url:'index.php/profile/uservalidation',
                data:$form.serialize(),
                type:"POST",
                dataType:"json",
                success:function(result){
                    if(result.success===true){
                        $form.attr("isSuccess","1");
                        $form.submit();
                    }else{
                         $form.attr("isSuccess","0");
                         $form.find('.alert').html(result.message).show();
                    }
                },
                async:false
            });
        }
        
        

    });
    
       // form validation
    $('#signup_form').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        }
    }).on('success.form.bv', function(e) {
        var $form = $(e.target);
        var isSuccess=$form.attr("isSuccess");        
        if(isSuccess==="0" || typeof isSuccess==="undefined"){
            
            e.preventDefault();
            $.ajax({
                url:'index.php/profile/checkemailexist',
                data:$form.serialize(),
                type:"POST",
                dataType:"json",
                success:function(result){
                    
                    if(result.success===true){
                        $form.attr("isSuccess","1");
                        $form.submit();
                    }else{
                         $form.attr("isSuccess","0");
                         $form.find('.alert').html(result.message).show();
                    }
                },
                async:false
            });
        }
    });
});